package com.leyou.item.client;

import com.leyou.common.vo.PageResult;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author syf
 * @version 1.0
 * @date 2019/08/05 09:16
 * @Description TODO:搜索微服务的FeignClient
 */
@FeignClient("item-service")
public interface ItemClient {

    /**
     * 查询规格参数信息
     * @return
     */
    @GetMapping("/spec/params")
    public List<SpecParamDTO> findParams(@RequestParam(value = "gid",required = false)Long gid,
                                                         @RequestParam(value = "cid",required = false)Long cid,
                                                         @RequestParam(value = "searching",required = false) Boolean searching);

    @GetMapping("/spu/page")
    public PageResult<SpuDTO> SpuPageQuery(@RequestParam(value = "page",defaultValue = "1") Integer page,
                                                           @RequestParam(value = "rows",defaultValue = "5") Integer rows,
                                                           @RequestParam(value = "key",required = false) String key,
                                                           @RequestParam(value = "saleable",required = false) Boolean saleable);


        /**
         * 修改商品信息
         * 根据spuID查询sku
         * @param id
         * @return
         */
    @GetMapping("/sku/of/spu")
    public List<SkuDTO> skuBySpuId(@RequestParam("id") Long id);

    /**
     * 修改商品信息
     * 查询SpuDetail接口
     * @param id
     * @return
     */
    @GetMapping("/spu/detail")
    public SpuDetailDTO SpuDetailById(@RequestParam("id") Long id);

    //根据品牌id批量查询品牌
    @GetMapping("/brand/list")
    public List<BrandDTO> findByBrand(@RequestParam("ids") List<Long> ids);


     //根据分类id集合查询分类集合
    @GetMapping("/category/list")
    public List<CategoryDto> findListById(@RequestParam("ids") List<Long> ids);

    //根据spuId查询spu信息
    @GetMapping("/spu/{id}")
    public SpuDTO findSpuIdBySpu(@PathVariable("id") Long id);

    //根据id查询品牌信息
    @GetMapping("/brand/{id}")
    public BrandDTO  findBrandById(@PathVariable("id") Long id);

    //根据categoryId查询规格参数组和组内参数
    @GetMapping("/spec/of/category")
    public List<SpecGroupDTO> findGroupByCidWithParams(@RequestParam("id") Long id);

    //根据sku的id集合获取sku集合信息
    @GetMapping("/sku/list")
    public List<SkuDTO> findSkuBuSkuIds(@RequestParam("ids") List<Long> ids);

    //减库存接口
    @PostMapping("/stock/minus")
    public Void minusStock(@RequestBody Map<Long, Integer> cartMap);
}
